<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
    </head>
    <body>
        <div id="demo" style="overflow:auto;height:180px;width:200px;background:#009900;color:#006600">  
        <table  align="top">  
        <tr>  
        <td id="demo1" valign="top">  

        <p>aaaaaaaaaaa</p>  
        <p>aaaaaaaaaaa</p>  
        <p>aaaaaaaaaaa</p>  
        <p>aaaaaaaaaaa</p>  
        <p>aaaaaaaaaaa</p>  
        <p>aaaaaaaaaaa</p>  


         </td>  
        </tr>  
        <tr>  
        <td id="demo2" valign="top"></td>  
        </tr>  
        </table>  

        </div>  
        <script>  
        var speed=15  
        demo2.innerHTML=demo1.innerHTML//克隆demo1为demo2  
        function Marquee(){  
        if(demo2.offsetHeight-demo.scrollTop<=0)//当滚动至demo1与demo2交界时  
        demo.scrollTop-=demo1.offsetHeight//demo跳到最顶端  
        else{  
        demo.scrollTop++  //如果是横向的 将 所有的 height top 改成 width left  
        }  
        }  
        var MyMar=setInterval(Marquee,speed)//设置定时器  
        demo.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的  
        demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器  
        </script>
    </body>
</html>